home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8513 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  46 lines

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: more problems with qsort
  5. Date: 02 Mar 1996 19:20:03 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Mar2122003@qcd.lanl.gov>
  8. References: <177399702S86.JW1675A@american.edu> <4h0j9e$ng5@clarknet.clark.net>
  9.     <4h8bud$1vd@castle.nando.net>
  10. NNTP-Posting-Host: qcd.lanl.gov
  11. Mime-Version: 1.0
  12. Content-Type: text
  13. In-reply-to: actuary@nando.net's message of 2 Mar 1996 02:31:41 GMT
  14.  
  15. In article <4h8bud$1vd@castle.nando.net>
  16. actuary@nando.net   (Bill McCarthy) writes:
  17.  
  18. <snip>
  19. BM: int compare( const void *a, const void *b )
  20. BM: {
  21. BM:    return strcmp( *(const char **)a, *(const char **)b );
  22. BM: }
  23.  
  24. Make that
  25.  
  26. int compare(const void *a, const void *b)
  27. {
  28.   char *const * x = a;
  29.   char *const * y = b;
  30.   return strcmp(*x,*y);
  31. }
  32.  
  33. Where I have shown only the `const's that I consider `necessary'. You
  34. may add any other consts that you like, but `casting a const away'
  35. always leaves a bad taste in my mouth, even if it is harmless.
  36.  
  37. Cheers
  38. Tanmoy
  39. --
  40. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  41. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  42. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  43. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  44. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  45. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  46.